package com.csdj.order.controller;

import com.alibaba.fastjson.JSON;
import com.csdj.order.entity.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class ProdutController {
    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/order/get/{id}")
    public String getProduct(@PathVariable String id){
        Product product = restTemplate.getForObject("http://localhost:8082/product/get/"+id, Product.class);
        product.setStatus("1");
        return JSON.toJSONString(product);
    }
}
